#ifndef SES_BUTTON_H_
#define SES_BUTTON_H_

#include "ses_common.h"
#include "ses_scheduler.h"



/*
 * Provides an interface for controlling the behavior of joystick and rotary
 * button.
 *
 * The behavior is defined by setting the callback functions.
 *
 * Further functions provide a check for the pressed status, used for
 * debouncing the buttons.
 */



// button wiring on SES board
#define BUTTON_ROTARY_PORT		PORTB
#define BUTTON_ROTARY_PIN		6
#define BUTTON_JOYSTICK_PORT	PORTB
#define BUTTON_JOYSTICK_PIN		7



/* Type of function pointer used as button callback */
typedef void (*pButtonCallback)();



/* Initializes rotary encoder and joystick button. */
void button_init(void);

/*
 * Sets callback for rotary encoder button pressed event.
 *
 * @param callback	a valid pointer to callback function or NULL to deactivate
 * 					the callback
 */
void button_setRotaryButtonCallback(pButtonCallback callback);

/*
 * Sets callback for joystick button pressed event.
 *
 * @param callback 	a valid pointer to callback function or NULL to deactivate
 * 					the callback
 */
void button_setJoystickButtonCallback(pButtonCallback callback);

/*
 * Checks if rotary button was pressed.
 */
bool rotary_pressed();

/*
 * Checks if joystick button was pressed.
 */
bool joystick_pressed();

void disable_pullup();

void enable_pullup();

#endif /* SES_BUTTON_H_ */
